package cn.wenhaha.app.log.controller;

import cn.wenhaha.common.bean.query.mapping.ErrorLogQuery;
import cn.wenhaha.app.log.bean.vo.ErrorLogVo;
import cn.wenhaha.app.log.service.ErrorLogService;
import cn.wenhaha.common.core.domain.AjaxV1Result;
import cn.wenhaha.common.db.bean.SysSyncError;
import com.jfinal.plugin.activerecord.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 错误日志模块
 * --------
 *
 * @author ：wyndem
 * @Date ：Created in 2023-01-19 21:05
 */
@RestController
@RequestMapping("/api/v1/error")
public class ErrorLogController {

    @Resource
    private ErrorLogService errorLogService;


    /**
     * <p>
     *    查看数据
     * </p>
     * @Author: Wyndem
     * @DateTime: 2023-01-20 15:01
     */
    @PostMapping("list")
    public AjaxV1Result<Page<ErrorLogVo>> list(@RequestBody ErrorLogQuery query){
        return  AjaxV1Result.newSuccess(errorLogService.list(query));
    }


    /**
     * <p>
     *    详情
     * </p>
     * @Author: Wyndem
     * @DateTime: 2023-01-20 15:13
     */
    @GetMapping("detail")
    public AjaxV1Result<SysSyncError> detail(@RequestParam("id") String id){
        return  AjaxV1Result.newSuccess(errorLogService.detail(id));
    }


    /**
     * <p>
     *    锁定切换
     * </p>
     * @Author: Wyndem
     * @DateTime: 2023-01-20 15:55
     */
    @GetMapping("change")
    public  AjaxV1Result<Boolean> lockChange(@RequestParam("id") String id){
        return  AjaxV1Result.newSuccess(errorLogService.lockChange(id));
    }
}
